package com.chen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chen.dto.DishDto;
import com.chen.entity.Dish;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper extends BaseMapper<Dish> {
    @Select("select dish.*,category.name as categoryName " +
            "from dish , category where dish.category_id=category.id " +
            "limit #{page},#{pagesize}")
    List<DishDto> selectPage(@Param("page")int page, @Param("pagesize")int pagesize);

    @Select("select dish.*,category.name as categoryName " +
            "from dish , category where dish.category_id=category.id " +
            "and dish.name like CONCAT('%',#{name},'%')limit #{page},#{pagesize}")
    List<DishDto> selectPageWithName(@Param("page")int page, @Param("pagesize")int pagesize, @Param("name") String name);

}
